//
// Created by deepin on 2020/11/12.
//

#include "stack.h"
Stack::Stack() {
    top=0;
}
//  bool Stack::isempty() const  代表不能修改类的成员变量(private public)
bool Stack::isempty() const {
    return top == 0;
}
//  bool Stack::isempty() const  代表不能修改类的成员变量(private public)
bool Stack::isfull() const {
    return top == Max;
}

bool Stack::push(const Item &item) {
    if (top<Max) {
      items[top++] = item;
      return true;
    }
    else {
      return false;
    }
}

bool Stack::pop(Item &item) {
    if (top>0) {
       item = items[--top];
       return true;
    }
    else {
       return false;
    }
}